import request from "./request.js"
import cookie from "./cookie.js"
//页面类型模块添加在这里,page_type_name对应页面类型中的脚本module属性
//import * as page_type_name from "./pagetype/page_type_name.js"
import * as crud_edit_page_type from "./pagetype/crud_edit_page_type.js"
import * as children_edit_page_type from "./pagetype/children_edit_page_type.js"
import * as one_select_multi_page_type from "./pagetype/one_select_multi_page_type.js"
import * as crud_quick_builder_page_type from "./pagetype/crud_quick_builder_page_type.js"
import * as form_visible_builder_page_type from "./pagetype/form_visible_builder_page_type.js"
import * as form_page_type from "./pagetype/form_page_type.js"
import * as amis_builder_page_type from "./pagetype/amis_builder_page_type.js"
import * as amis_page_type from "./pagetype/amis_page_type.js"
import * as html_builder_page_type from "./pagetype/html_builder_page_type.js"
import * as html_page_type from "./pagetype/html_page_type.js"
import * as report_builder_page_type from "./pagetype/report_builder_page_type.js"
import * as report_page_type from "./pagetype/report_page_type.js"
//BPM
import * as process_builder_page_type from "./apps/bpm/pagetype/process_builder_page_type.js"
import * as process_approve_page_type from "./apps/bpm/pagetype/process_approve_page_type.js"
//MES
import * as mes_process_page_type from "./pagetype/mes_process_page_type.js"
import * as INPUT from "./mes/INPUT.js"
import * as BCC from "./mes/BCC.js"

let page = {
	open: function (html_id, pageid, params) { //params为页面跳转时附带参数
		if (!pageid) {
			$("#" + html_id).empty();
			return;
		}
		let path = "page/info";
		request(path, { "id": pageid }, function (data) {
			if (data.length == 0) {
				alert("未获取到页面数据");
			}
			let type_js = data.js;
			let property = data.property;
			let ext_js = data.ext_js;
			let rights = data.rights;
			let login_info = data.login_info;
			$("#" + html_id).empty();
			let page_html_id = "page_" + pageid + "_" + new Date().getTime();
			$("#" + html_id).html('<div id="' + page_html_id + '" class="app-wrapper ei-page ei-page-type-' + type_js + '"></div>');
			let info = {
				page_html_id: page_html_id,
				property: property,
				ext_js: ext_js,
				pageid: pageid,
				rights: rights,
				login_info: login_info,
				params: params
			}
			eval(type_js).default.open(info);
		})
	},
	open_by_type: function (html_id, type_js, property, ext_js) {
		let page_html_id = type_js + "_" + new Date().getTime();
		$("#" + html_id).empty();
		$("#" + html_id).html('<div id="' + page_html_id + '" class="app-wrapper ei-page ei-page-type-' + type_js + '"></div>');
		let info = {
			page_html_id: page_html_id,
			property: property,
			ext_js: ext_js,
			login_info: {
				username: cookie.getcookie("username"),
				user_id: cookie.getcookie("user_id"),
				emp_id: cookie.getcookie("emp_id"),
				emp_name: cookie.getcookie("emp_name"),
				org_id: cookie.getcookie("org_id"),
				org_name: cookie.getcookie("org_name"),
				job_number: cookie.getcookie("job_number"),
				position_id: cookie.getcookie("position_id"),
				position_name: cookie.getcookie("position_name"),
			}
		}
		eval(type_js).default.open(info);
	}
};

export default page;